package com.ruoyi.stream.service.streamService;

import com.ruoyi.stream.framework.annotations.StreamServiceEndpoint;
import com.ruoyi.stream.framework.core.protocol.SKAProtocolContext;
import com.ruoyi.stream.framework.core.protocol.StreamAliveRequest;
import com.ruoyi.stream.framework.core.protocol.StreamAliveResponse;
import com.ruoyi.stream.framework.model.StreamServiceEndpointHandler;
import com.ruoyi.stream.framework.model.configBuilder.IOTaskConfigBuilder;
import org.springframework.stereotype.Component;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;

@Component
@StreamServiceEndpoint(uri = "/video")
public class VideoService implements StreamServiceEndpointHandler {
    @Override
    public Object onRequest(StreamAliveRequest request, StreamAliveResponse response) {
        return null;
    }

    @Override
    public boolean onReady(StreamAliveRequest request, SKAProtocolContext context, IOTaskConfigBuilder<?> config) {
        return true;
    }

    @Override
    public InputStream start(StreamAliveRequest request, SKAProtocolContext context) {
        try {
            return new FileInputStream("D:\\SpringBoo3\\streamvedio\\test\\src\\main\\resources\\test.mp4");
        } catch (FileNotFoundException e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public void onError(StreamAliveRequest request, StreamAliveResponse response) {

    }

    @Override
    public void onRefuse(StreamAliveRequest request, StreamAliveResponse response) {

    }
}
